module Spec             
  module Rails
    module Behaviors
      # A set of reuseable behaviors that should work with restfully architected applications
      module Controllers
      
        describe "a successful action", :shared => true do
          it "should be successful" do
            do_get
            response.should be_success
          end
        end

        describe "an index action", :shared => true do
          it_should_behave_like "a successful action"  
  
          it "should render index template" do
            do_get
            response.should render_template('index')
          end
        end

        describe "a standard index action", :shared => true do
          it_should_behave_like "an index action"  
          it_should_behave_like "an action that sets header tags"    
        end

        describe "a show action", :shared => true do
          it_should_behave_like "a successful action"  
  
          it "should render show template" do
            do_get
            response.should render_template('show')
          end
        end
 
        describe "a standard show action", :shared => true do
          it_should_behave_like "an action that sets header tags"  
          it_should_behave_like "a show action"  
        end
 
        describe "a show action without a layout", :shared => true do
          it_should_behave_like "a successful action"  
          it_should_behave_like "a show action"  
        end
 
        describe "a standard new action", :shared => true do
          it_should_behave_like "a successful action"  
  
          it "should render new template" do
            do_get
            response.should render_template('new')
          end
        end

        describe "a standard edit action", :shared => true do
          it_should_behave_like "a successful action"  
  
          it "should render edit template" do
            do_get
            response.should render_template('edit')
          end
        end

        # Tests that a variable is set that is used for the browser title. This variable name maybe need to be changed for your application.
        describe "an action that sets header tags", :shared => true do
          it "should set a title tag" do 
            do_get
            assigns[:page_title].should_not be_nil 
          end
        end         
      
        # Tests that variables are set that are used for the meta tags. This variable names maybe need to be changed for your application.
        describe "an action that sets meta tags", :shared => true do
          it "should set meta keywords" do 
            do_get
            assigns[:page_keywords].should_not be_nil 
          end      
        
          it "should set meta description" do 
            do_get
            assigns[:page_description].should_not be_nil 
          end
        end         
      
      end
    end
  end
end

